home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / manual-p / man_db-2.000 / man_db-2 / man_db-2.3.10 / lib / basename.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-25  |  820 b   |  35 lines

  1. /*
  2.  * basename.c: take path as argument, return basename.
  3.  *  
  4.  * Copyright (C), 1994, 1995, Graeme W. Wilford. (Wilf.)
  5.  *
  6.  * You may distribute under the terms of the GNU Library General Public
  7.  * License as specified in the file COPYING.LIB that comes with this
  8.  * distribution.
  9.  *
  10.  * Thu Dec  8 20:43:47 GMT 1994  Wilf. (G.Wilford@ee.surrey.ac.uk) 
  11.  */
  12.  
  13. #ifdef HAVE_CONFIG_H
  14. #  include "config.h"
  15. #endif /* HAVE_CONFIG_H */
  16.  
  17. #if defined(STDC_HEADERS)
  18. #  include <string.h>
  19. #elif defined(HAVE_STRING_H)
  20. #  include <string.h>
  21. #elif defined(HAVE_STRINGS_H)
  22. #  include <strings.h>
  23. #else /* no string(s) header */
  24. extern char *strrchr();
  25. #endif /* STDC_HEADERS */
  26.  
  27. /* return basename of given filename */
  28. char *basename(char *filename)
  29. {
  30.     char *base;
  31.  
  32.     base = strrchr(filename, '/');
  33.     return base ? base + 1 : filename;
  34. }
  35.